<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ page import="java.sql.*,java.util.*,dao.FixDao" %>
    
           <%
	//检查会话中是否有 "sg" 属性
	Object fdyObj = session.getAttribute("sg");
	if (fdyObj == null) {
	    response.sendRedirect("Login.jsp");
	    return;
	}
%>   
    
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>宿管页面</title>
<link href="../css/Utils.css" rel="stylesheet" type="text/css" />
<link href="../css/List.css" rel="stylesheet" type="text/css" />
<!-- 退出登录专用 -->
    <script type="text/javascript" src="Loginout.js"></script>
</head>
<body>

<!-- 头部 -->
<div class="header" ><br>
<nerong>&nbsp;&nbsp;学生页面&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;</nerong>

 <button onclick="confirmLogout('<%= (String)session.getAttribute("student") %>','student')">退出登录</button>

</div><br>

<div class="left" >
<table width="80%" height="80%">
<th>
<nerong>宿管可选择内容</nerong>

</th>
<tr>
<td>
<a href="../View_Msg/msgSg.jsp">&emsp;个人信息</a><br>
</td>
</tr>

<tr>
<td>
<a href="../View_SuShe/SuSheSG_List.jsp">&emsp;楼栋学生信息查询</a><br>
</td>
</tr>
<tr>

<td bgcolor=#1a7dba>
<a href="../View_fix/SgFix.jsp">&emsp;公物报修</a><br>

</td>
</tr>

<tr>
<td>
<a href = "../View_WeiGui/WeiGuiSG.jsp">&emsp;宿舍违规信息处理</a><br>
</td>
</tr>

</table>

</div>



<div class="context" >


<!-- 报修表单内容 -->
   <div style="background-color:#a5d4f1;width:160px">
     <a href="SgFix.jsp">返回报修页面</a>
    </div>
<h2 align="center">维修提交记录</h2>


 <%
        String userId = request.getParameter("userId");
        if (userId != null && !userId.isEmpty()) {
            try {
                FixDao fixDao = new FixDao();
                List<Map<String, Object>> fixes = fixDao.getFixesById(userId);
 
                if (fixes != null && !fixes.isEmpty()) {
                    out.println("<table class='Alltable'>");
                    out.println("<tr><th>ID</th><th>楼号</th><th>楼层</th><th>宿舍号</th><th>时间</th><th>详情</th></tr>");
                    for (Map<String, Object> fix : fixes) {
                        out.println("<tr>");
                        out.println("<td>" + fix.get("Fix_id") + "</td>");
                        out.println("<td>" + fix.get("Fix_Buliding") + "</td>");
                        out.println("<td>" + fix.get("Fix_floor") + "</td>");
                        out.println("<td>" + fix.get("Fix_BuilNum") + "</td>");
                        out.println("<td>" + fix.get("Fix_Time") + "</td>");
                        out.println("<td>" + fix.get("Fix_detail") + "</td>");
                        out.println("</tr>");
                    }
                    out.println("</table>");
                } else {
                    out.println("<p>没有找到报修记录。</p>");
                }
            } catch (Exception e) {
                e.printStackTrace();
                out.println("<p>发生错误，无法显示报修记录。</p>");
            }
        } else {
            out.println("<p>用户ID缺失，无法显示报修记录。</p>");
        }
    %>
 
   



</div>

</body>
</html>